import { messages } from "share/common";

export default {
  formatControlData(data, values) {
    data.shieldRoomType = values.shieldRoomType ? "1" : ""; // 屏蔽行政房
    data.shieldByTravelStandard = values.shieldByTravelStandard; // 屏蔽房价
    data.enabledCheckRepeatBooking = values.enabledCheckRepeatBooking; // 屏蔽房价
    data.controlAgreement = values.agreement.controlAgreement; // 协议价酒店控制
    data.enabledCheckRepeatBooking = values.enabledCheckRepeatBooking; // 重复预定
    if (values.agreement.controlAgreement) {
      data.controlAgreementWay = values.agreement.controlAgreementWay; // 协议价酒店的管控强度
    }
    data.reasonForNotAgreementList = values.reasonForNotAgreementList;

    data.enabledTravelApprovalControl = values.enabledTravelApprovalControl;
    if (values.enabledTravelApprovalControl) {
      // 是否开启审批单管控
      const { travelApprovalControl } = data;
      travelApprovalControl.enabledNoApproval = values.approvalList.enabledNoApproval;
      travelApprovalControl.enabledDynamicAmount = values.enabledDynamicAmount;
      if (values.approvalList.noApprovalUserGroupId_ === "userId") {
        // 是否选择人员组
        travelApprovalControl.noApprovalUserGroupId = values.approvalList.noApprovalUserGroupId;
      } else if (travelApprovalControl.enabledNoApproval) {
        travelApprovalControl.noApprovalUserGroupId = "all";
      }
      const other = Object.assign(
        {},
        values.approvalDate,
        values.approvalNight,
        values.approvalSite,
        values.approvalAmount,
        values.approvalPeople
      );
      data.travelApprovalControl = Object.assign({}, travelApprovalControl, other);
    }
    data.enabledTravelStandardsControl = values.enabledTravelStandardsControl;
    if (values.enabledTravelStandardsControl) {
      // 是否开启差标管控
      const { travelStandardsControl } = data;
      const travel = Object.assign({}, values.travelStar, values.travelPrice);
      data.travelStandardsControl = Object.assign({}, travelStandardsControl, travel);
    }
    data.reasonForBeyondStandardsList = values.reasonForBeyondStandardsList; // 超标理由
    data.promptForBeyondStandards = values.promptForBeyondStandards; // 超标提示语
    return data;
  },
  // 酒店协议
  getAgreementForm() {
    return {
      checkboxKey: "controlAgreement",
      radioKey: "controlAgreementWay",
      checkboxOpt: {
        text: messages("supplier-1.key35") /*启用temp*/,
      },
      radioOpt: [
        { key: 30, text: messages("supplier-1.key308") /*强管控*/ },
        { key: 10, text: messages("supplier-1.key309") /*弱管控*/ },
      ],
    };
  },
  getApprovalForm(type) {
    const rad = [
      { key: 30, text: messages("supplier-1.key308") /*强管控*/ },
      { key: 10, text: messages("supplier-1.key309") /*弱管控*/ },
    ];
    switch (type) {
      case "list": // 部分员工预订无须审批单
        return {
          checkboxKey: "enabledNoApproval",
          radioKey: "noApprovalUserGroupId_",
          checkboxOpt: {
            text: messages("supplier-1.key312") /*部分员工预订无须审批单*/,
          },
          radioOpt: [
            { key: "all", text: messages("supplier-1.key128") /*通用*/ },
            {
              key: "userId",
              text: messages("supplier-1.key311") /*从人员组选择*/,
            },
          ],
          userGroup: true,
        };
      case "date": // 离店日期管控
        return {
          checkboxKey: "controlDate",
          radioKey: "controlDateWay",
          checkboxOpt: {
            text: messages("supplier-1.key470") /*入住离店日期*/,
          },
          radioOpt: rad,
        };
      case "night": // 间夜数管控
        return {
          checkboxKey: "controlRoomNight",
          radioKey: "controlRoomNightWay",
          checkboxOpt: {
            text: messages("supplier-1.key471") /*总间夜数*/,
          },
          radioOpt: rad,
        };
      case "site": // 地点管控
        return {
          checkboxKey: "controlSite",
          radioKey: "controlSiteWay",
          checkboxOpt: {
            text: messages("supplier-1.key472") /*地点*/,
          },
          radioOpt: rad,
        };
      case "amount": // 金额管控
        return {
          checkboxKey: "controlMaxPrice",
          radioKey: "controlMaxPriceWay",
          checkboxOpt: {
            text: messages("common.total.amount") /*总金额*/,
          },
          radioOpt: rad,
        };
      case "people": // 入住人管控
        return {
          checkboxKey: "controlGuest",
          radioKey: "controlGuestWay",
          checkboxOpt: {
            text: messages("supplier-1.key94") /*入住人*/,
          },
          radioOpt: rad,
        };
      case "star": // 差标管控 星级
        return {
          checkboxKey: "controlStar",
          radioKey: "controlStarWay",
          checkboxOpt: {
            text: messages("supplier-1.key473") /*星级控制*/,
          },
          radioOpt: rad,
        };
      case "price": // 差标管控 价格控制
        return {
          checkboxKey: "controlPrice",
          radioKey: "controlPriceWay",
          checkboxOpt: {
            text: messages("supplier-1.key474") /*价格控制*/,
          },
          radioOpt: rad,
        };
    }
  },
  huazhuHotel(type) {
    if (type === "column") {
      return [
        { title: "ID", dataIndex: "id", width: 160 },
        {
          title: messages("supplier-1.key475") /*酒店名称（不提供早餐）*/,
          dataIndex: "name",
        },
        {
          title: messages("supplier-1.key476") /*酒店地址*/,
          dataIndex: "address",
        },
      ];
    } else if (type === "data") {
      return [
        {
          id: "8000220",
          name: messages("supplier-1.key477") /*桔子精选杭州文一西路酒店*/,
          address: messages("supplier-1.key478") /*杭州市西湖区文一西路50号（益乐路天皇大厦对面）*/,
        },
        {
          id: "8000221",
          name: messages("supplier-1.key479") /*桔子水晶杭州钱江新城近江酒店*/,
          address: messages("supplier-1.key480") /*杭州市上城区钱江路555号*/,
        },
        {
          id: "2000105",
          name: messages("supplier-1.key481") /*桔子精选上海豫园酒店*/,
          address: messages("supplier-1.key482") /*上海黄浦区人民路399号*/,
        },
      ];
    }
  },
};
